﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using StructureMap;

namespace DLM.DependencyResolve
{
    public class IoCControllerFactory : DefaultControllerFactory, IControllerActivator
    {

        protected override IController GetControllerInstance(RequestContext requestContext, Type controllerType)
        {
            IController controller = null;
            if (controllerType != null)
            {
                controller = ObjectFactory.GetInstance(controllerType) as IController;
            }
            return controller;
            //return base.GetControllerInstance(requestContext, controllerType);
        }

        public IController Create(RequestContext requestContext, Type controllerType)
        {
            return ObjectFactory.GetInstance(controllerType) as IController;
        }
    }
}
